home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / corewars / interfac.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-14  |  2.0 KB  |  102 lines

  1. /**********************************************************************
  2.  *                                       *
  3.  *                                       *
  4.  *            Copyright 1989 By Case T. Larsen              *
  5.  *              All Rights Reserved                  *
  6.  *                                          *
  7.  *                                          *
  8.  **********************************************************************/
  9.  
  10. #include <pixrect/pixrect_hs.h>
  11. #include "interp.h"
  12.  
  13. #define Y(x) (((x)/100)*5)
  14. #define X(x) (((x)%100)*5)
  15.  
  16. static struct pixrect *screen;
  17. static struct pixrect *bm;
  18. static bitm[8000];
  19. static xpos[8000], ypos[8000];
  20.  
  21. xcore_init ()
  22. {
  23.   int i;
  24.  
  25.   screen = pr_open("/dev/fb");
  26.   bm = mem_create(500,400,1);
  27.   for (i=0; i<8000;i++) {
  28.     bitm[i] = 0;
  29.     xpos[i] = X(i); ypos[i] = Y(i);
  30.     zero(xpos[i],ypos[i]);
  31.   }
  32.   pr_rop (screen,0,0,500,400,PIX_SRC,bm,0,0);
  33. } /* xcore_init */
  34.  
  35. zero (x,y)
  36.      int x,y;
  37. {
  38.   pr_put (bm,x,y,1);
  39.   pr_put (bm,x,y+1,1);
  40.   pr_put (bm,x,y+2,1);
  41.   pr_put (bm,x+1,y,1);
  42.   pr_put (bm,x+1,y+1,1);
  43.   pr_put (bm,x+1,y+2,1);
  44.   pr_put (bm,x+2,y,1);
  45.   pr_put (bm,x+2,y+1,1);
  46.   pr_put (bm,x+2,y+2,1);
  47. } /* zero */
  48.  
  49. one (x,y)
  50.      int x,y;
  51. {
  52.   pr_put (bm,x,y,0);
  53.   pr_put (bm,x,y+1,0);
  54.   pr_put (bm,x,y+2,0);
  55.   pr_put (bm,x+1,y,0);
  56.   pr_put (bm,x+1,y+1,0);
  57.   pr_put (bm,x+1,y+2,0);
  58.   pr_put (bm,x+2,y,0);
  59.   pr_put (bm,x+2,y+1,0);
  60.   pr_put (bm,x+2,y+2,0);
  61. } /* zero */
  62.  
  63. two (x,y)
  64.      int x,y;
  65. {
  66.   pr_put (bm,x,y,1);
  67.   pr_put (bm,x,y+1,0);
  68.   pr_put (bm,x,y+2,0);
  69.   pr_put (bm,x+1,y,0);
  70.   pr_put (bm,x+1,y+1,1);
  71.   pr_put (bm,x+1,y+2,0);
  72.   pr_put (bm,x+2,y,0);
  73.   pr_put (bm,x+2,y+1,0);
  74.   pr_put (bm,x+2,y+2,1);
  75. } /* zero */
  76.  
  77. xcore_display (mem)
  78.      cell mem[];
  79. {
  80.   register int i;
  81.   register int owner;
  82.  
  83.   for (i=0;i<8000;i++) {
  84.     if (mem[i].lastmod != bitm[i]) {
  85.       owner = bitm[i] = mem[i].lastmod;
  86.       if (owner) {
  87.     if (owner == 1) {
  88.       one (xpos[i],ypos[i]);
  89.     } else
  90.       two (xpos[i],ypos[i]);
  91.       } else
  92.     zero (xpos[i],ypos[i]);
  93.     }
  94.   }
  95.   pr_rop (screen,0,0,500,400,PIX_SRC,bm,0,0);
  96. } /* xcore_display */
  97.  
  98. xcore_done ()
  99. {
  100.   pr_close(screen);
  101. } /* xcore_done */
  102.